package top.withu.gaof.freehope.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;
import top.withu.gaof.freehope.annotate.PassCheck;
import top.withu.gaof.freehope.model.ArticleModel;
import top.withu.gaof.freehope.model.Comment;
import top.withu.gaof.freehope.res.ArticleRes;
import top.withu.gaof.freehope.service.CommentService;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 评论控制层
 * @Author: gaofan
 * @Date: 2019/10/9 13:57
 * @Copyright: 2019 www.freehope.top Inc. All rights reserved.
 **/
@RestController
@Api("文章评论")
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private CommentService commentService;

    @GetMapping("/article")
    @PassCheck
    @ApiOperation(value = "获取文章的评论", notes = "获取未失效评论", tags = "comment module")
    public List<Comment> getDocs(@Param("docId") Integer docId) {
        return commentService.getByDocId(docId);
    }

    @PostMapping("/article")
    @PassCheck
    @ApiOperation(value = "插入评论", notes = "插入评论", tags = "comment module")
    public void updateDoc(@RequestBody
            Comment comment) {
        commentService.insert(comment);
    }
}
